/**
 * 
 */
package xiaojian.toolkit.bean.xip.meta;

import java.util.Collection;

import org.apache.commons.collections4.Transformer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import xiaojian.toolkit.bean.util.meta.BeanMetainfoUtils;
import xiaojian.toolkit.bean.util.meta.Int2TypeMetainfo;
import xiaojian.toolkit.bean.xip.annotation.SsipSignal;

/**
 * @author hp
 * 
 */
public class MetainfoUtils {

	@SuppressWarnings("unused")
	private static final Logger logger = LoggerFactory
			.getLogger(MetainfoUtils.class);

	private static final Transformer SSIP_CLS2INT = new Transformer() {

		public Object transform(Object input) {
			Class<?> cls = (Class<?>) input;
			SsipSignal attr = cls.getAnnotation(SsipSignal.class);
			return null != attr ? attr.messageCode() : null;
		}
	};

	static public Int2TypeMetainfo createSsipTypeMetainfo(
			Collection<String> packages) {
		return BeanMetainfoUtils.createTypeMetainfo(packages, SSIP_CLS2INT);
	}

	static public Int2TypeMetainfo createSsipTypeMetainfoByClasses(
			Collection<Class<?>> clazzes) {
		return BeanMetainfoUtils.createTypeMetainfoByClasses(clazzes,
				SSIP_CLS2INT);
	}

}
